package chapter4.avoiding_constructor_confusion;

import org.springframework.context.support.GenericXmlApplicationContext;

public class ConstructorConfusion {
	private String someValue;

	public ConstructorConfusion(String someValue, String name) {
		System.out.println("ConstructorConfusion(String) called" + someValue
				+ "\t" + name);
		this.someValue = someValue;
	}

	public ConstructorConfusion(int someValue, String name) {
		System.out.println("ConstructorConfusion(int) called");
		this.someValue = "Number : " + Integer.toString(someValue);
	}

	@Override
	public String toString() {
		return someValue;
	}

	public static void main(String[] args) {
		GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
		ctx.load("classpath:chapter4/avoiding_constructor_confusion/app-context-xml.xml");
		ctx.refresh();

		ConstructorConfusion confusion = (ConstructorConfusion) ctx
				.getBean("constructorConfusion");
		System.out.println(confusion);
	}
}
